/*
 * Copyright (c) 2020 solidwang. All rights reserved.
 */

package com.solidwang.mybatis.mapper;
import com.solidwang.mybatis.model.User;
import org.apache.ibatis.annotations.*;

import java.util.Date;
import java.util.List;

@Mapper
public interface UserMapper {

    @Insert("insert into user(name,age,ctime,utime) values(#{name},#{age},#{ctime, jdbcType=TIMESTAMP},#{utime, jdbcType=TIMESTAMP})")
    int insert(@Param("name") String name, @Param("age") Integer age, @Param("ctime") Date ctime, @Param("utime") Date utime);

    @Select("select * from user where id =#{id}")
    User findById(@Param("id") Integer id);

    @Update("update user set name=#{name} where id=#{id}")
    void updataById(@Param("id") Integer id, @Param("name") String name);

    @Delete("delete from user where id=#{id}")
    void deleteById(@Param("id") Integer id);

    @Select("select * from user")
    List<User> findAllUser();

}
